meson: Use proxy-libintl subproject when needed and available
authorNirbheek Chauhan <nirbheek@centricular.com>
Fri, 6 Jul 2018 18:50:41 +0000 (00:20 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Fri, 12 Oct 2018 07:38:48 +0000 (13:08 +0530)
Such as on Windows with MSVC.

meson.build

index 5e48265cd4260dd2c55fbf90750563c49fbe5853..1483353cfad834558fcf7016f072eaba1f5d507a 100644 (file)
@@ -591,9 +591,24 @@ endif
 # Check for bind_textdomain_codeset, including -lintl if GLib brings it in by
 # doing the same check as glib. We can't check that by linking to glib because
 # it might be a subproject and hence not built yet.
-libintl_dep = cc.find_library('intl', required : false)
-if cc.has_function('bind_textdomain_codeset', dependencies: libintl_dep)
+if cc.has_function('ngettext')
+  libintl_dep = []
   cdata.set('HAVE_BIND_TEXTDOMAIN_CODESET', 1)
+else
+  libintl_dep = cc.find_library('intl', required : false)
+  if cc.has_function('bind_textdomain_codeset', dependencies: libintl_dep)
+    cdata.set('HAVE_BIND_TEXTDOMAIN_CODESET', 1)
+  else
+    # Don't use subproject('proxy-libintl').get_variable('intl_dep') because that
+    # makes the dependency unconditional. This way, people have the option of
+    # either not providing the subproject or disabling it entirely with
+    # --wrap-mode=nodownload or nofallback.
+    libintl_dep = dependency('', required : false,
+                             fallback: ['proxy-libintl', 'intl_dep'])
+    if libintl_dep.found()
+      cdata.set('HAVE_BIND_TEXTDOMAIN_CODESET', 1)
+    endif
+  endif
 endif
 
 if os_unix